<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:pe="http://primefaces.org/ui/extensions">

    <h:body>

        <ui:composition template="/resources/template/template.xhtml">

            <ui:define name="content">
                <h:form>


                    <p:panel header="Non Moving Stock Report" >

                        <p:panelGrid columns="2" styleClass="alignTop" >

                            <h:panelGrid columns="2"  >
                                <h:outputLabel value="Department" ></h:outputLabel>
                                <p:autoComplete completeMethod="#{departmentController.completeDept}" var="dept" itemLabel="#{dept.name}" itemValue="#{dept}" forceSelection="true" value="#{reportsStock.department}" converter="departmentConverter" >
                                </p:autoComplete>

                                <h:outputLabel value="From" ></h:outputLabel>
                                <p:calendar value="#{reportsStock.fromDateE}" pattern="dd/MMM/yyyy - hh:mm:ss a" ></p:calendar>

                                <h:outputLabel value="To" ></h:outputLabel>
                                <p:calendar value="#{reportsStock.toDateE}" pattern="dd/MMM/yyyy - hh:mm:ss a" ></p:calendar>

                                <h:outputLabel value="Category" ></h:outputLabel>
                                <p:autoComplete completeMethod="#{pharmaceuticalItemCategoryController.completeCategory}" var="cat" 
                                                itemLabel="#{cat.name}" itemValue="#{cat}" forceSelection="true" value="#{reportsStock.category}"
                                                >
                                </p:autoComplete>


                                <h:outputLabel value="Movement Type" ></h:outputLabel>
                                <p:selectCheckboxMenu value="#{reportsStock.billTypes}" label="Bill Types"  >
                                    <f:selectItems value="#{enumController.pharmacyBillTypes3}" var="pbt" itemLabel="#{pbt.label}" itemValue="#{pbt}" ></f:selectItems>
                                </p:selectCheckboxMenu>

                            </h:panelGrid>

                            <h:panelGrid columns="1" >
                                <h:panelGrid columns="4" >
                                    <p:commandButton ajax="false" value="Process" actionListener="#{reportsStock.fillDepartmentNonmovingStocks}" ></p:commandButton>
                                    <p:commandButton ajax="false" value="Three Months Nonmoving" actionListener="#{reportsStock.fillThreeMonthsNonmoving()}" ></p:commandButton>
                                    <p:commandButton ajax="false" value="Six Months Nonmoving" actionListener="#{reportsStock.fillSixMonthsNonmoving()}" ></p:commandButton>
                                    <p:commandButton ajax="false" value="One Year Nonmoving" actionListener="#{reportsStock.fillOneYearNonmoving()}" ></p:commandButton>

                                </h:panelGrid>
                                <h:panelGrid columns="4" >
                                    <p:commandButton value="Print" ajax="false" >
                                        <p:printer target="gpBillPreview" ></p:printer>
                                    </p:commandButton>
                                    <p:commandButton value="Excel" ajax="false">
                                        <pe:exporter type="xlsx" target="tbl" fileName="Total Stock"
                                                     facetBackground="#008000" facetFontSize="15" 
                                                     facetFontColor="#FFFFFF" facetFontStyle="BOLD" cellFontColor="#0000FF" cellFontSize="12"  cellFontStyle="NORMAL" 
                                                     fontName="Courier New" />
                                    </p:commandButton>
                                </h:panelGrid>

                            </h:panelGrid>

                        </p:panelGrid>

                        <h:panelGroup id="gpBillPreview"   style="min-width: 100%!important;">
                            <p:dataTable id="tbl"  value="#{reportsStock.items}" var="i"  
                                         rows="10"
                                         paginator="true"
                                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                         rowsPerPageTemplate="5,10,15"
                                         >
                                <f:facet name="header">
                                    <h:outputLabel value="Non Moving Stocks - #{reportsStock.department.name}"/>                                     
                                </f:facet>   
                                <p:column headerText="Category" 
                                          sortBy="#{i.category.name}"
                                          filterBy="#{i.category.name}"
                                          filterMatchMode="contains"
                                          >
                                    <h:outputLabel value="#{i.category.name}" ></h:outputLabel>
                                </p:column>
                                <p:column headerText="Item" 
                                          sortBy="#{i.name}"
                                          filterBy="#{i.name}"
                                          filterMatchMode="contains"
                                          >
                                    <h:outputLabel value="#{i.name}" ></h:outputLabel>
                                </p:column>

                                <p:column headerText="Code"
                                          sortBy="#{i.code}"
                                          filterBy="#{i.code}"
                                          filterMatchMode="contains"
                                          >
                                    <f:facet name="header">
                                        <h:outputLabel value="Code"/>
                                    </f:facet>
                                    <h:outputLabel value="#{i.code}" ></h:outputLabel>
                                </p:column>
                            </p:dataTable>
                        </h:panelGroup>
                    </p:panel>
                </h:form>


            </ui:define>


        </ui:composition>

    </h:body>
</html>
